/**
 * 
 */
package com.thor.palmmall.rest.position.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.communicate.converter.UCNConverter;
import com.thor.palmmall.rest.position.APosition;
import com.thor.palmmall.spi.position.SPosition;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class APositionConverter implements Converter<SPosition, APosition> {

  public static APositionConverter getInstance() {
    if (instance == null)
      instance = new APositionConverter();
    return instance;
  }

  private static APositionConverter instance;

  private APositionConverter() {
  }

  @Override
  public APosition convert(SPosition source) {
    if (source == null) {
      return null;
    }
    APosition target = new APosition();
    target.setBeginDate(source.getBeginDate());
    target.setBizType(UCN.newInstance(source.getBizType()));
    target.setBrands(ConverterUtil.convert(source.getBrands(), UCNConverter.getInstance()));
    target.setBuildingArea(source.getBuildingArea());
    target.setCode(source.getCode());
    target.setContract(UCN.newInstance(source.getContract()));
    target.setEndDate(source.getEndDate());
    target.setManageFeePrice(source.getManageFeePrice());
    target.setName(source.getName());
    target.setPrice(source.getPrice());
    target.setRentArea(source.getRentArea());
    target.setState(source.getState());
    target.setStore(UCN.newInstance(source.getStore()));
    return target;
  }

}
